<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>perlrun - how to execute the Perl interpreter - Perldoc Browser</title>
    <link rel="search" href="https://perldoc.perl.org/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser">
    <link rel="canonical" href="https://perldoc.perl.org/perlrun">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/stackoverflow-light.min.css" integrity="sha512-cG1IdFxqipi3gqLmksLtuk13C+hBa57a6zpWxMeoY3Q9O6ooFxq50DayCdm0QrDgZjMUn23z/0PMZlgft7Yp5Q==" crossorigin="anonymous" />
    <style>
      body {
        background: #f4f4f5;
        color: #020202;
      }
      .navbar-dark {
        background-image: -webkit-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: -o-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: linear-gradient(to bottom, #005f85 0, #002e49 100%);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff005f85', endColorstr='#ff002e49', GradientType=0);
        background-repeat: repeat-x;
      }
      .navbar-dark .navbar-nav .nav-link,
      .navbar-dark .navbar-nav .nav-link:focus { color: #fff }
      .navbar-dark .navbar-nav .nav-link:hover { color: #ffef68 }
      #wrapperlicious {
        margin: 0 auto;
        font: 0.9em 'Helvetica Neue', Helvetica, sans-serif;
        font-weight: normal;
        line-height: 1.5em;
        margin: 0;
        padding: 0;
      }
      #wrapperlicious h1 { font-size: 1.5em }
      #wrapperlicious h2 { font-size: 1.3em }
      #wrapperlicious h3 { font-size: 1.1em }
      #wrapperlicious h4 { font-size: 0.9em }
      #wrapperlicious h1, #wrapperlicious h2, #wrapperlicious h3,
      #wrapperlicious h4, #wrapperlicious dt {
        color: #020202;
        margin-top: 1em;
        margin-bottom: 1em;
        position: relative;
        font-weight: bold;
      }
      #wrapperlicious a { color: inherit; text-decoration: underline }
      #wrapperlicious #toc { text-decoration: none }
      #wrapperlicious a:hover { color: #2a2a2a }
      #wrapperlicious a img { border: 0 }
      #wrapperlicious :not(pre) > code {
        color: inherit;
        background-color: rgba(0, 0, 0, 0.04);
        border-radius: 3px;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        padding: 0.3em;
      }
      #wrapperlicious dd {
        margin: 0;
        margin-left: 2em;
      }
      #wrapperlicious dt {
        color: #2a2a2a;
        font-weight: bold;
        margin-left: 0.9em;
      }
      #wrapperlicious p {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious li > p {
        margin-bottom: 0;
        margin-top: 0;
      }
      #wrapperlicious pre {
        border: 1px solid #c1c1c1;
        border-radius: 3px;
        font: 100% Consolas, Menlo, Monaco, monospace;
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious pre > code {
        display: block;
        background-color: #f6f6f6;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        line-height: 1.5em;
        text-align: left;
        white-space: pre;
        padding: 1em;
      }
      #wrapperlicious dl, #wrapperlicious ol, #wrapperlicious ul {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious ul {
        list-style-type: square;
      }
      #wrapperlicious ul ul {
        margin-bottom: 0px;
        margin-top: 0px;
      }
      #footer {
        font-size: 0.8em;
        padding-top: 0.5em;
        text-align: center;
      }
      #more {
        display: inline;
        font-size: 0.8em;
      }
      #perldocdiv {
        background-color: #fff;
        border: 1px solid #c1c1c1;
        border-bottom-left-radius: 5px;
        border-bottom-right-radius: 5px;
        margin-left: auto;
        margin-right: auto;
        padding: 3em;
        padding-top: 1em;
        max-width: 960px;
      }
      #moduleversion { float: right }
      #wrapperlicious .leading-notice {
        font-style: italic;
        padding-left: 1em;
        margin-top: 1em;
        margin-bottom: 1em;
      }
      #wrapperlicious .permalink {
        display: none;
        left: -0.75em;
        position: absolute;
        padding-right: 0.25em;
        text-decoration: none;
      }
      #wrapperlicious h1:hover .permalink, #wrapperlicious h2:hover .permalink,
      #wrapperlicious h3:hover .permalink, #wrapperlicious h4:hover .permalink,
      #wrapperlicious dt:hover .permalink {
        display: block;
      }
    </style>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-KVNWBNT5FB"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-KVNWBNT5FB');
      gtag('config', 'UA-50555-3');
    </script>
  </head>
  <body>
    <nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-between">
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="https://perldoc.perl.org/">Perldoc Browser</a>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="perlrun.html#" id="dropdownlink-stable" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">5.35.0</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-stable">
          <a class="dropdown-item" href="https://perldoc.perl.org/perlrun">Latest</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.2/perlrun">5.38.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.1/perlrun">5.38.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0/perlrun">5.38.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.3/perlrun">5.36.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.2/perlrun">5.36.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.1/perlrun">5.36.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.0/perlrun">5.36.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.3/perlrun">5.34.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.2/perlrun">5.34.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.1/perlrun">5.34.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.0/perlrun">5.34.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.1/perlrun">5.32.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.0/perlrun">5.32.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.3/perlrun">5.30.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.2/perlrun">5.30.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.1/perlrun">5.30.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.0/perlrun">5.30.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.3/perlrun">5.28.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.2/perlrun">5.28.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.1/perlrun">5.28.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.0/perlrun">5.28.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.3/perlrun">5.26.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.2/perlrun">5.26.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.1/perlrun">5.26.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.0/perlrun">5.26.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.4/perlrun">5.24.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.3/perlrun">5.24.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.2/perlrun">5.24.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.1/perlrun">5.24.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.0/perlrun">5.24.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.4/perlrun">5.22.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.3/perlrun">5.22.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.2/perlrun">5.22.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.1/perlrun">5.22.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.0/perlrun">5.22.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.3/perlrun">5.20.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.2/perlrun">5.20.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.1/perlrun">5.20.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.0/perlrun">5.20.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.4/perlrun">5.18.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.3/perlrun">5.18.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.2/perlrun">5.18.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.1/perlrun">5.18.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.0/perlrun">5.18.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.3/perlrun">5.16.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.2/perlrun">5.16.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.1/perlrun">5.16.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.0/perlrun">5.16.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.4/perlrun">5.14.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.3/perlrun">5.14.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.2/perlrun">5.14.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.1/perlrun">5.14.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.0/perlrun">5.14.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.5/perlrun">5.12.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.4/perlrun">5.12.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.3/perlrun">5.12.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.2/perlrun">5.12.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.1/perlrun">5.12.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.0/perlrun">5.12.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.1/perlrun">5.10.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.0/perlrun">5.10.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.9/perlrun">5.8.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.8/perlrun">5.8.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.7/perlrun">5.8.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.6/perlrun">5.8.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.5/perlrun">5.8.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.4/perlrun">5.8.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.3/perlrun">5.8.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.2/perlrun">5.8.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.1/perlrun">5.8.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.0/perlrun">5.8.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.2/perlrun">5.6.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.1/perlrun">5.6.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.0/perlrun">5.6.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_04/perlrun">5.005_04</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_03/perlrun">5.005_03</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_02/perlrun">5.005_02</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_01/perlrun">5.005_01</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005/perlrun">5.005</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="perlrun.html#" id="dropdownlink-dev" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dev</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-dev">
          <a class="dropdown-item" href="https://perldoc.perl.org/blead/perlrun">blead</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.6/perlrun">5.39.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.5/perlrun">5.39.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.4/perlrun">5.39.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.3/perlrun">5.39.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.2/perlrun">5.39.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.1/perlrun">5.39.1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC2/perlrun">5.38.0-RC2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC1/perlrun">5.38.0-RC1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.11/perlrun">5.37.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.10/perlrun">5.37.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.9/perlrun">5.37.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.8/perlrun">5.37.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.7/perlrun">5.37.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.6/perlrun">5.37.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.5/perlrun">5.37.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.4/perlrun">5.37.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.3/perlrun">5.37.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.2/perlrun">5.37.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.1/perlrun">5.37.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.0/perlrun">5.37.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.11/perlrun">5.35.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.10/perlrun">5.35.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.9/perlrun">5.35.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.8/perlrun">5.35.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.7/perlrun">5.35.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.6/perlrun">5.35.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.5/perlrun">5.35.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.4/perlrun">5.35.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.3/perlrun">5.35.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.2/perlrun">5.35.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.1/perlrun">5.35.1</a>
          <a class="dropdown-item active" href="perlrun.html">5.35.0</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="perlrun.html#" id="dropdownlink-nav" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Documentation</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-nav">
          <a class="dropdown-item" href="perl.html">Perl</a>
          <a class="dropdown-item" href="perlintro.html">Intro</a>
          <a class="dropdown-item" href="perl.html#Tutorials">Tutorials</a>
          <a class="dropdown-item" href="perlfaq.html">FAQs</a>
          <a class="dropdown-item" href="perl.html#Reference-Manual">Reference</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlop.html">Operators</a>
          <a class="dropdown-item" href="functions.html">Functions</a>
          <a class="dropdown-item" href="variables.html">Variables</a>
          <a class="dropdown-item" href="modules.html">Modules</a>
          <a class="dropdown-item" href="perlutil.html">Utilities</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlcommunity.html">Community</a>
          <a class="dropdown-item" href="perlhist.html">History</a>
        </div>
      </li>
    </ul>
    <ul class="navbar-nav">
      <script>
        function set_expand (expand) {
          var perldocdiv = document.getElementById('perldocdiv');
          var width = window.getComputedStyle(perldocdiv).getPropertyValue('max-width');
          var expanded = (width == '' || width == 'none') ? true : false;
          if (expand === null) {
            expand = !expanded;
          }
          if ((expand && !expanded) || (!expand && expanded)) {
            perldocdiv.style.setProperty('max-width', expand ? 'none' : '960px');
            var button_classlist = document.getElementById('content-expand-button').classList;
            if (expand) {
              button_classlist.add('btn-light');
              button_classlist.remove('btn-outline-light');
            } else {
              button_classlist.add('btn-outline-light');
              button_classlist.remove('btn-light');
            }
          }
          return expand;
        }
        function toggle_expand () {
          var expand = set_expand(null);
          document.cookie = 'perldoc_expand=' + (expand ? 1 : 0) + '; path=/; expires=Tue, 19 Jan 2038 03:14:07 UTC';
        }
        function read_expand () {
          return document.cookie.split(';').some(function (item) { return item.indexOf('perldoc_expand=1') >= 0 });
        }
        if (document.readyState === 'loading') {
          document.addEventListener('DOMContentLoaded', function () {
            if (read_expand()) {
              set_expand(true);
            }
          });
        } else if (read_expand()) {
          set_expand(true);
        }
      </script>
      <button id="content-expand-button" type="button" class="btn btn-outline-light d-none d-lg-inline-block mr-2" onclick="toggle_expand()">Expand</button>
    <ul>
    <form class="form-inline" method="get" action="https://perldoc.perl.org/5.35.0/search">
      <input class="form-control mr-3" type="search" name="q" placeholder="Search" aria-label="Search">
    </form>
  </div>
</nav>

    <div id="wrapperlicious" class="container-fluid">
      <div id="perldocdiv">
        <div id="links">
          <a href="perlrun.html">perlrun</a>
          <div id="more">
            (<a href="perlrun.txt">source</a>,
            <a href="https://metacpan.org/pod/perlrun">CPAN</a>)
          </div>
        </div>
        <div class="leading-notice">
          You are viewing the version of this documentation from Perl 5.35.0.
            This is a development version of Perl.
        </div>
        <h1><a id="toc">CONTENTS</a></h1>
                  <ul>
              <li>
                <a class="text-decoration-none" href="perlrun.html#NAME">NAME</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlrun.html#SYNOPSIS">SYNOPSIS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlrun.html#DESCRIPTION">DESCRIPTION</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="perlrun.html#%23!-and-quoting-on-non-Unix-systems">#! and quoting on non-Unix systems  </a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlrun.html#Location-of-Perl">Location of Perl </a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlrun.html#Command-Switches">Command Switches  </a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="perlrun.html#ENVIRONMENT">ENVIRONMENT </a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlrun.html#ORDER-OF-APPLICATION">ORDER OF APPLICATION</a>
              </li>
          </ul>

      <h1 id="NAME"><a class="permalink" href="perlrun.html#NAME">#</a>NAME</h1>

<p>perlrun - how to execute the Perl interpreter</p>

<h1 id="SYNOPSIS"><a class="permalink" href="perlrun.html#SYNOPSIS">#</a>SYNOPSIS</h1>

<p><b>perl</b> <span style="white-space: nowrap;">[ <b>-sTtuUWX</b> ]</span> <span style="white-space: nowrap;">[ <b>-hv</b> ] [ <b>-V</b>[:<i>configvar</i>] ]</span> <span style="white-space: nowrap;">[ <b>-cw</b> ] [ <b>-d</b>[<b>t</b>][:<i>debugger</i>] ] [ <b>-D</b>[<i>number/list</i>] ]</span> <span style="white-space: nowrap;">[ <b>-pna</b> ] [ <b>-F</b><i>pattern</i> ] [ <b>-l</b>[<i>octal</i>] ] [ <b>-0</b>[<i>octal/hexadecimal</i>] ]</span> <span style="white-space: nowrap;">[ <b>-I</b><i>dir</i> ] [ <b>-m</b>[<b>-</b>]<i>module</i> ] [ <b>-M</b>[<b>-</b>]<i>&#39;module...&#39;</i> ] [ <b>-f</b> ]</span> <span style="white-space: nowrap;">[ <b>-C [<i>number/list</i>] </b>]</span> <span style="white-space: nowrap;">[ <b>-S</b> ]</span> <span style="white-space: nowrap;">[ <b>-x</b>[<i>dir</i>] ]</span> <span style="white-space: nowrap;">[ <b>-i</b>[<i>extension</i>] ]</span> <span style="white-space: nowrap;">[ [<b>-e</b>|<b>-E</b>] <i>&#39;command&#39;</i> ] [ <b>--</b> ] [ <i>programfile</i> ] [ <i>argument</i> ]...</span></p>

<h1 id="DESCRIPTION"><a class="permalink" href="perlrun.html#DESCRIPTION">#</a>DESCRIPTION</h1>

<p>The normal way to run a Perl program is by making it directly executable, or else by passing the name of the source file as an argument on the command line. (An interactive Perl environment is also possible--see <a href="perldebug.html">perldebug</a> for details on how to do that.) Upon startup, Perl looks for your program in one of the following places:</p>

<ol>

<li><p>Specified line by line via <a href="perlrun.html#-e-commandline">-e</a> or <a href="perlrun.html#-E-commandline">-E</a> switches on the command line.</p>

</li>
<li><p>Contained in the file specified by the first filename on the command line. (Note that systems supporting the <code>#!</code> notation invoke interpreters this way. See <a href="perlrun.html#Location-of-Perl">&quot;Location of Perl&quot;</a>.)</p>

</li>
<li><p>Passed in implicitly via standard input. This works only if there are no filename arguments--to pass arguments to a STDIN-read program you must explicitly specify a &quot;-&quot; for the program name.</p>

</li>
</ol>

<p>With methods 2 and 3, Perl starts parsing the input file from the beginning, unless you&#39;ve specified a <a href="perlrun.html#-x">&quot;-x&quot;</a> switch, in which case it scans for the first line starting with <code>#!</code> and containing the word &quot;perl&quot;, and starts there instead. This is useful for running a program embedded in a larger message. (In this case you would indicate the end of the program using the <code>__END__</code> token.)</p>

<p>The <code>#!</code> line is always examined for switches as the line is being parsed. Thus, if you&#39;re on a machine that allows only one argument with the <code>#!</code> line, or worse, doesn&#39;t even recognize the <code>#!</code> line, you still can get consistent switch behaviour regardless of how Perl was invoked, even if <a href="perlrun.html#-x">&quot;-x&quot;</a> was used to find the beginning of the program.</p>

<p>Because historically some operating systems silently chopped off kernel interpretation of the <code>#!</code> line after 32 characters, some switches may be passed in on the command line, and some may not; you could even get a &quot;-&quot; without its letter, if you&#39;re not careful. You probably want to make sure that all your switches fall either before or after that 32-character boundary. Most switches don&#39;t actually care if they&#39;re processed redundantly, but getting a &quot;-&quot; instead of a complete switch could cause Perl to try to execute standard input instead of your program. And a partial <a href="perlrun.html#-Idirectory">-I</a> switch could also cause odd results.</p>

<p>Some switches do care if they are processed twice, for instance combinations of <a href="perlrun.html#-l%5Boctnum%5D">-l</a> and <a href="perlrun.html#-0%5Boctal%2Fhexadecimal%5D">-0</a>. Either put all the switches after the 32-character boundary (if applicable), or replace the use of <b>-0</b><i>digits</i> by <code>BEGIN{ $/ = &quot;\0digits&quot;; }</code>.</p>

<p>Parsing of the <code>#!</code> switches starts wherever &quot;perl&quot; is mentioned in the line. The sequences &quot;-*&quot; and &quot;- &quot; are specifically ignored so that you could, if you were so inclined, say</p>

<pre><code>#!/bin/sh
#! -*- perl -*- -p
eval &#39;exec perl -x -wS $0 ${1+&quot;$@&quot;}&#39;
    if 0;</code></pre>

<p>to let Perl see the <a href="perlrun.html#-p">&quot;-p&quot;</a> switch.</p>

<p>A similar trick involves the <i>env</i> program, if you have it.</p>

<pre><code class="plaintext">#!/usr/bin/env perl</code></pre>

<p>The examples above use a relative path to the perl interpreter, getting whatever version is first in the user&#39;s path. If you want a specific version of Perl, say, perl5.14.1, you should place that directly in the <code>#!</code> line&#39;s path.</p>

<p>If the <code>#!</code> line does not contain the word &quot;perl&quot; nor the word &quot;indir&quot;, the program named after the <code>#!</code> is executed instead of the Perl interpreter. This is slightly bizarre, but it helps people on machines that don&#39;t do <code>#!</code>, because they can tell a program that their SHELL is <i>/usr/bin/perl</i>, and Perl will then dispatch the program to the correct interpreter for them.</p>

<p>After locating your program, Perl compiles the entire program to an internal form. If there are any compilation errors, execution of the program is not attempted. (This is unlike the typical shell script, which might run part-way through before finding a syntax error.)</p>

<p>If the program is syntactically correct, it is executed. If the program runs off the end without hitting an exit() or die() operator, an implicit <code>exit(0)</code> is provided to indicate successful completion.</p>

<h2 id="#!-and-quoting-on-non-Unix-systems"><a class="permalink" href="perlrun.html#%23!-and-quoting-on-non-Unix-systems">#</a><a id="and-quoting-on-non-Unix-systems"></a>#! and quoting on non-Unix systems  </h2>

<p>Unix&#39;s <code>#!</code> technique can be simulated on other systems:</p>

<dl>

<dt id="OS/2"><a class="permalink" href="perlrun.html#OS/2">#</a><a id="OS"></a><a id="OS-2"></a>OS/2</dt>
<dd>

<p>Put</p>

<pre><code class="plaintext">extproc perl -S -your_switches</code></pre>

<p>as the first line in <code>*.cmd</code> file (<a href="perlrun.html#-S">&quot;-S&quot;</a> due to a bug in cmd.exe&#39;s `extproc&#39; handling).</p>

</dd>
<dt id="MS-DOS"><a class="permalink" href="perlrun.html#MS-DOS">#</a><a id="MS"></a>MS-DOS</dt>
<dd>

<p>Create a batch file to run your program, and codify it in <code>ALTERNATE_SHEBANG</code> (see the <i>dosish.h</i> file in the source distribution for more information).</p>

</dd>
<dt id="Win95/NT"><a class="permalink" href="perlrun.html#Win95/NT">#</a><a id="Win95"></a><a id="Win95-NT"></a>Win95/NT</dt>
<dd>

<p>The Win95/NT installation, when using the ActiveState installer for Perl, will modify the Registry to associate the <i>.pl</i> extension with the perl interpreter. If you install Perl by other means (including building from the sources), you may have to modify the Registry yourself. Note that this means you can no longer tell the difference between an executable Perl program and a Perl library file.</p>

</dd>
<dt id="VMS"><a class="permalink" href="perlrun.html#VMS">#</a>VMS</dt>
<dd>

<p>Put</p>

<pre><code>$ perl -mysw &#39;f$env(&quot;procedure&quot;)&#39; &#39;p1&#39; &#39;p2&#39; &#39;p3&#39; &#39;p4&#39; &#39;p5&#39; &#39;p6&#39; &#39;p7&#39; &#39;p8&#39; !
$ exit++ + ++$status != 0 and $exit = $status = undef;</code></pre>

<p>at the top of your program, where <b>-mysw</b> are any command line switches you want to pass to Perl. You can now invoke the program directly, by saying <code>perl program</code>, or as a DCL procedure, by saying <code>@program</code> (or implicitly via <i>DCL$PATH</i> by just using the name of the program).</p>

<p>This incantation is a bit much to remember, but Perl will display it for you if you say <code>perl &quot;-V:startperl&quot;</code>.</p>

</dd>
</dl>

<p>Command-interpreters on non-Unix systems have rather different ideas on quoting than Unix shells. You&#39;ll need to learn the special characters in your command-interpreter (<code>*</code>, <code>\</code> and <code>&quot;</code> are common) and how to protect whitespace and these characters to run one-liners (see <a href="perlrun.html#-e-commandline">-e</a> below).</p>

<p>On some systems, you may have to change single-quotes to double ones, which you must <i>not</i> do on Unix or Plan 9 systems. You might also have to change a single % to a %%.</p>

<p>For example:</p>

<pre><code class="plaintext"># Unix
perl -e &#39;print &quot;Hello world\n&quot;&#39;

# MS-DOS, etc.
perl -e &quot;print \&quot;Hello world\n\&quot;&quot;

# VMS
perl -e &quot;print &quot;&quot;Hello world\n&quot;&quot;&quot;</code></pre>

<p>The problem is that none of this is reliable: it depends on the command and it is entirely possible neither works. If <i>4DOS</i> were the command shell, this would probably work better:</p>

<pre><code class="plaintext">perl -e &quot;print &lt;Ctrl-x&gt;&quot;Hello world\n&lt;Ctrl-x&gt;&quot;&quot;</code></pre>

<p><b>CMD.EXE</b> in Windows NT slipped a lot of standard Unix functionality in when nobody was looking, but just try to find documentation for its quoting rules.</p>

<p>There is no general solution to all of this. It&#39;s just a mess.</p>

<h2 id="Location-of-Perl"><a class="permalink" href="perlrun.html#Location-of-Perl">#</a><a id="Location"></a>Location of Perl </h2>

<p>It may seem obvious to say, but Perl is useful only when users can easily find it. When possible, it&#39;s good for both <i>/usr/bin/perl</i> and <i>/usr/local/bin/perl</i> to be symlinks to the actual binary. If that can&#39;t be done, system administrators are strongly encouraged to put (symlinks to) perl and its accompanying utilities into a directory typically found along a user&#39;s PATH, or in some other obvious and convenient place.</p>

<p>In this documentation, <code>#!/usr/bin/perl</code> on the first line of the program will stand in for whatever method works on your system. You are advised to use a specific path if you care about a specific version.</p>

<pre><code class="plaintext">#!/usr/local/bin/perl5.14</code></pre>

<p>or if you just want to be running at least version, place a statement like this at the top of your program:</p>

<pre><code>use 5.014;</code></pre>

<h2 id="Command-Switches"><a class="permalink" href="perlrun.html#Command-Switches">#</a><a id="Command"></a>Command Switches  </h2>

<p>As with all standard commands, a single-character switch may be clustered with the following switch, if any.</p>

<pre><code class="plaintext">#!/usr/bin/perl -spi.orig	# same as -s -p -i.orig</code></pre>

<p>A <code>--</code> signals the end of options and disables further option processing. Any arguments after the <code>--</code> are treated as filenames and arguments.</p>

<p>Switches include:</p>

<dl>

<dt id="-0[octal/hexadecimal]"><a class="permalink" href="perlrun.html#-0%5Boctal/hexadecimal%5D">#</a><a id="octal-hexadecimal"></a><b>-0</b>[<i>octal/hexadecimal</i>]  </dt>
<dd>

<p>specifies the input record separator (<code>$/</code>) as an octal or hexadecimal number. If there are no digits, the null character is the separator. Other switches may precede or follow the digits. For example, if you have a version of <i>find</i> which can print filenames terminated by the null character, you can say this:</p>

<pre><code class="plaintext">find . -name &#39;*.orig&#39; -print0 | perl -n0e unlink</code></pre>

<p>The special value 00 will cause Perl to slurp files in paragraph mode. Any value 0400 or above will cause Perl to slurp files whole, but by convention the value 0777 is the one normally used for this purpose.</p>

<p>You can also specify the separator character using hexadecimal notation: <b>-0x<i>HHH...</i></b>, where the <code><i>H</i></code> are valid hexadecimal digits. Unlike the octal form, this one may be used to specify any Unicode character, even those beyond 0xFF. So if you <i>really</i> want a record separator of 0777, specify it as <b>-0x1FF</b>. (This means that you cannot use the <a href="perlrun.html#-x">&quot;-x&quot;</a> option with a directory name that consists of hexadecimal digits, or else Perl will think you have specified a hex number to <b>-0</b>.)</p>

</dd>
<dt id="-a"><a class="permalink" href="perlrun.html#-a">#</a><a id="a"></a><b>-a</b>  </dt>
<dd>

<p>turns on autosplit mode when used with a <a href="perlrun.html#-n">&quot;-n&quot;</a> or <a href="perlrun.html#-p">&quot;-p&quot;</a>. An implicit split command to the @F array is done as the first thing inside the implicit while loop produced by the <a href="perlrun.html#-n">&quot;-n&quot;</a> or <a href="perlrun.html#-p">&quot;-p&quot;</a>.</p>

<pre><code>perl -ane &#39;print pop(@F), &quot;\n&quot;;&#39;</code></pre>

<p>is equivalent to</p>

<pre><code>    while (&lt;&gt;) {
	@F = split(&#39; &#39;);
	print pop(@F), &quot;\n&quot;;
    }</code></pre>

<p>An alternate delimiter may be specified using <a href="perlrun.html#-Fpattern">-F</a>.</p>

<p><b>-a</b> implicitly sets <a href="perlrun.html#-n">&quot;-n&quot;</a>.</p>

</dd>
<dt id="-C-[number/list]"><a class="permalink" href="perlrun.html#-C-%5Bnumber/list%5D">#</a><a id="C-number-list"></a><b>-C [<i>number/list</i>]</b> </dt>
<dd>

<p>The <b>-C</b> flag controls some of the Perl Unicode features.</p>

<p>As of 5.8.1, the <b>-C</b> can be followed either by a number or a list of option letters. The letters, their numeric values, and effects are as follows; listing the letters is equal to summing the numbers.</p>

<pre><code>I     1   STDIN is assumed to be in UTF-8
O     2   STDOUT will be in UTF-8
E     4   STDERR will be in UTF-8
S     7   I + O + E
i     8   UTF-8 is the default PerlIO layer for input streams
o    16   UTF-8 is the default PerlIO layer for output streams
D    24   i + o
A    32   the @ARGV elements are expected to be strings encoded
          in UTF-8
L    64   normally the &quot;IOEioA&quot; are unconditional, the L makes
          them conditional on the locale environment variables
          (the LC_ALL, LC_CTYPE, and LANG, in the order of
          decreasing precedence) -- if the variables indicate
          UTF-8, then the selected &quot;IOEioA&quot; are in effect
a   256   Set ${^UTF8CACHE} to -1, to run the UTF-8 caching
          code in debugging mode.</code></pre>

<p>For example, <b>-COE</b> and <b>-C6</b> will both turn on UTF-8-ness on both STDOUT and STDERR. Repeating letters is just redundant, not cumulative nor toggling.</p>

<p>The <code>io</code> options mean that any subsequent open() (or similar I/O operations) in main program scope will have the <code>:utf8</code> PerlIO layer implicitly applied to them, in other words, UTF-8 is expected from any input stream, and UTF-8 is produced to any output stream. This is just the default set via <a href="perlvar.html#%24%7B%5EOPEN%7D"><code>${^OPEN}</code></a>, with explicit layers in open() and with binmode() one can manipulate streams as usual. This has no effect on code run in modules.</p>

<p><b>-C</b> on its own (not followed by any number or option list), or the empty string <code>&quot;&quot;</code> for the <a href="perlrun.html#PERL_UNICODE">&quot;PERL_UNICODE&quot;</a> environment variable, has the same effect as <b>-CSDL</b>. In other words, the standard I/O handles and the default <code>open()</code> layer are UTF-8-fied <i>but</i> only if the locale environment variables indicate a UTF-8 locale. This behaviour follows the <i>implicit</i> (and problematic) UTF-8 behaviour of Perl 5.8.0. (See <a href="perl581delta.html#UTF-8-no-longer-default-under-UTF-8-locales">&quot;UTF-8 no longer default under UTF-8 locales&quot; in perl581delta</a>.)</p>

<p>You can use <b>-C0</b> (or <code>&quot;0&quot;</code> for <code>PERL_UNICODE</code>) to explicitly disable all the above Unicode features.</p>

<p>The read-only magic variable <code>${^UNICODE}</code> reflects the numeric value of this setting. This variable is set during Perl startup and is thereafter read-only. If you want runtime effects, use the three-arg open() (see <a href="perlfunc.html#open">&quot;open&quot; in perlfunc</a>), the two-arg binmode() (see <a href="perlfunc.html#binmode">&quot;binmode&quot; in perlfunc</a>), and the <code>open</code> pragma (see <a href="open.html">open</a>).</p>

<p>(In Perls earlier than 5.8.1 the <b>-C</b> switch was a Win32-only switch that enabled the use of Unicode-aware &quot;wide system call&quot; Win32 APIs. This feature was practically unused, however, and the command line switch was therefore &quot;recycled&quot;.)</p>

<p><b>Note:</b> Since perl 5.10.1, if the <b>-C</b> option is used on the <code>#!</code> line, it must be specified on the command line as well, since the standard streams are already set up at this point in the execution of the perl interpreter. You can also use binmode() to set the encoding of an I/O stream.</p>

</dd>
<dt id="-c"><a class="permalink" href="perlrun.html#-c">#</a><a id="c"></a><b>-c</b> </dt>
<dd>

<p>causes Perl to check the syntax of the program and then exit without executing it. Actually, it <i>will</i> execute any <code>BEGIN</code>, <code>UNITCHECK</code>, or <code>CHECK</code> blocks and any <code>use</code> statements: these are considered as occurring outside the execution of your program. <code>INIT</code> and <code>END</code> blocks, however, will be skipped.</p>

</dd>
<dt id="-d"><a class="permalink" href="perlrun.html#-d">#</a><a id="d"></a><b>-d</b>  </dt>
<dd>

</dd>
<dt id="-dt"><a class="permalink" href="perlrun.html#-dt">#</a><a id="dt"></a><b>-dt</b></dt>
<dd>

<p>runs the program under the Perl debugger. See <a href="perldebug.html">perldebug</a>. If <b>t</b> is specified, it indicates to the debugger that threads will be used in the code being debugged.</p>

</dd>
<dt id="-d:MOD[=bar,baz]"><a class="permalink" href="perlrun.html#-d:MOD%5B=bar,baz%5D">#</a><a id="d:MOD-bar-baz"></a><b>-d:</b><i>MOD[=bar,baz]</i>  </dt>
<dd>

</dd>
<dt id="-dt:MOD[=bar,baz]"><a class="permalink" href="perlrun.html#-dt:MOD%5B=bar,baz%5D">#</a><a id="dt:MOD-bar-baz"></a><b>-dt:</b><i>MOD[=bar,baz]</i></dt>
<dd>

<p>runs the program under the control of a debugging, profiling, or tracing module installed as <code>Devel::<i>MOD</i></code>. E.g., <b>-d:DProf</b> executes the program using the <code>Devel::DProf</code> profiler. As with the <a href="perlrun.html#-M%5B-%5Dmodule">-M</a> flag, options may be passed to the <code>Devel::<i>MOD</i></code> package where they will be received and interpreted by the <code>Devel::<i>MOD</i>::import</code> routine. Again, like <b>-M</b>, use -<b>-d:-<i>MOD</i></b> to call <code>Devel::<i>MOD</i>::unimport</code> instead of import. The comma-separated list of options must follow a <code>=</code> character. If <b>t</b> is specified, it indicates to the debugger that threads will be used in the code being debugged. See <a href="perldebug.html">perldebug</a>.</p>

</dd>
<dt id="-Dletters"><a class="permalink" href="perlrun.html#-Dletters">#</a><a id="Dletters"></a><b>-D</b><i>letters</i>   </dt>
<dd>

</dd>
<dt id="-Dnumber"><a class="permalink" href="perlrun.html#-Dnumber">#</a><a id="Dnumber"></a><b>-D</b><i>number</i></dt>
<dd>

<p>sets debugging flags. This switch is enabled only if your perl binary has been built with debugging enabled: normal production perls won&#39;t have been.</p>

<p>For example, to watch how perl executes your program, use <b>-Dtls</b>. Another nice value is <b>-Dx</b>, which lists your compiled syntax tree, and <b>-Dr</b> displays compiled regular expressions; the format of the output is explained in <a href="perldebguts.html">perldebguts</a>.</p>

<p>As an alternative, specify a number instead of list of letters (e.g., <b>-D14</b> is equivalent to <b>-Dtls</b>):</p>

<pre><code class="plaintext">        1  p  Tokenizing and parsing (with v, displays parse
              stack)
        2  s  Stack snapshots (with v, displays all stacks)
        4  l  Context (loop) stack processing
        8  t  Trace execution
       16  o  Method and overloading resolution
       32  c  String/numeric conversions
       64  P  Print profiling info, source file input state
      128  m  Memory and SV allocation
      256  f  Format processing
      512  r  Regular expression parsing and execution
     1024  x  Syntax tree dump
     2048  u  Tainting checks
     4096  U  Unofficial, User hacking (reserved for private,
              unreleased use)
    16384  X  Scratchpad allocation
    32768  D  Cleaning up
    65536  S  Op slab allocation
   131072  T  Tokenizing
   262144  R  Include reference counts of dumped variables
              (eg when using -Ds)
   524288  J  show s,t,P-debug (don&#39;t Jump over) on opcodes within
              package DB
  1048576  v  Verbose: use in conjunction with other flags to
              increase the verbosity of the output.  Is a no-op on
              many of the other flags
  2097152  C  Copy On Write
  4194304  A  Consistency checks on internal structures
  8388608  q  quiet - currently only suppresses the &quot;EXECUTING&quot;
              message
 16777216  M  trace smart match resolution
 33554432  B  dump suBroutine definitions, including special
              Blocks like BEGIN
 67108864  L  trace Locale-related info; what gets output is very
              subject to change
134217728  i  trace PerlIO layer processing.  Set PERLIO_DEBUG to
              the filename to trace to.
268435456  y  trace y///, tr/// compilation and execution</code></pre>

<p>All these flags require <b>-DDEBUGGING</b> when you compile the Perl executable (but see <code>:opd</code> in <a href="./Devel::Peek.html">Devel::Peek</a> or <a href="re.html#%27debug%27-mode">&quot;&#39;debug&#39; mode&quot; in re</a> which may change this). See the <i>INSTALL</i> file in the Perl source distribution for how to do this.</p>

<p>If you&#39;re just trying to get a print out of each line of Perl code as it executes, the way that <code>sh -x</code> provides for shell scripts, you can&#39;t use Perl&#39;s <b>-D</b> switch. Instead do this</p>

<pre><code class="plaintext"># If you have &quot;env&quot; utility
env PERLDB_OPTS=&quot;NonStop=1 AutoTrace=1 frame=2&quot; perl -dS program

# Bourne shell syntax
$ PERLDB_OPTS=&quot;NonStop=1 AutoTrace=1 frame=2&quot; perl -dS program

# csh syntax
% (setenv PERLDB_OPTS &quot;NonStop=1 AutoTrace=1 frame=2&quot;; perl -dS program)</code></pre>

<p>See <a href="perldebug.html">perldebug</a> for details and variations.</p>

</dd>
<dt id="-e-commandline"><a class="permalink" href="perlrun.html#-e-commandline">#</a><a id="e-commandline"></a><b>-e</b> <i>commandline</i> </dt>
<dd>

<p>may be used to enter one line of program. If <b>-e</b> is given, Perl will not look for a filename in the argument list. Multiple <b>-e</b> commands may be given to build up a multi-line script. Make sure to use semicolons where you would in a normal program.</p>

</dd>
<dt id="-E-commandline"><a class="permalink" href="perlrun.html#-E-commandline">#</a><a id="E-commandline"></a><b>-E</b> <i>commandline</i> </dt>
<dd>

<p>behaves just like <a href="perlrun.html#-e-commandline">-e</a>, except that it implicitly enables all optional features (in the main compilation unit). See <a href="feature.html">feature</a>.</p>

</dd>
<dt id="-f"><a class="permalink" href="perlrun.html#-f">#</a><a id="f"></a><b>-f</b>   </dt>
<dd>

<p>Disable executing <i>$Config{sitelib}/sitecustomize.pl</i> at startup.</p>

<p>Perl can be built so that it by default will try to execute <i>$Config{sitelib}/sitecustomize.pl</i> at startup (in a BEGIN block). This is a hook that allows the sysadmin to customize how Perl behaves. It can for instance be used to add entries to the @INC array to make Perl find modules in non-standard locations.</p>

<p>Perl actually inserts the following code:</p>

<pre><code>BEGIN {
    do { local $!; -f &quot;$Config{sitelib}/sitecustomize.pl&quot;; }
        &amp;&amp; do &quot;$Config{sitelib}/sitecustomize.pl&quot;;
}</code></pre>

<p>Since it is an actual <code>do</code> (not a <code>require</code>), <i>sitecustomize.pl</i> doesn&#39;t need to return a true value. The code is run in package <code>main</code>, in its own lexical scope. However, if the script dies, <code>$@</code> will not be set.</p>

<p>The value of <code>$Config{sitelib}</code> is also determined in C code and not read from <code>Config.pm</code>, which is not loaded.</p>

<p>The code is executed <i>very</i> early. For example, any changes made to <code>@INC</code> will show up in the output of `perl -V`. Of course, <code>END</code> blocks will be likewise executed very late.</p>

<p>To determine at runtime if this capability has been compiled in your perl, you can check the value of <code>$Config{usesitecustomize}</code>.</p>

</dd>
<dt id="-Fpattern"><a class="permalink" href="perlrun.html#-Fpattern">#</a><a id="Fpattern"></a><b>-F</b><i>pattern</i> </dt>
<dd>

<p>specifies the pattern to split on for <a href="perlrun.html#-a">&quot;-a&quot;</a>. The pattern may be surrounded by <code>//</code>, <code>&quot;&quot;</code>, or <code>&#39;&#39;</code>, otherwise it will be put in single quotes. You can&#39;t use literal whitespace or NUL characters in the pattern.</p>

<p><b>-F</b> implicitly sets both <a href="perlrun.html#-a">&quot;-a&quot;</a> and <a href="perlrun.html#-n">&quot;-n&quot;</a>.</p>

</dd>
<dt id="-h"><a class="permalink" href="perlrun.html#-h">#</a><a id="h"></a><b>-h</b> </dt>
<dd>

<p>prints a summary of the options.</p>

</dd>
<dt id="-i[extension]"><a class="permalink" href="perlrun.html#-i%5Bextension%5D">#</a><a id="i-extension"></a><b>-i</b>[<i>extension</i>]  </dt>
<dd>

<p>specifies that files processed by the <code>&lt;&gt;</code> construct are to be edited in-place. It does this by renaming the input file, opening the output file by the original name, and selecting that output file as the default for print() statements. The extension, if supplied, is used to modify the name of the old file to make a backup copy, following these rules:</p>

<p>If no extension is supplied, and your system supports it, the original <i>file</i> is kept open without a name while the output is redirected to a new file with the original <i>filename</i>. When perl exits, cleanly or not, the original <i>file</i> is unlinked.</p>

<p>If the extension doesn&#39;t contain a <code>*</code>, then it is appended to the end of the current filename as a suffix. If the extension does contain one or more <code>*</code> characters, then each <code>*</code> is replaced with the current filename. In Perl terms, you could think of this as:</p>

<pre><code>($backup = $extension) =~ s/\*/$file_name/g;</code></pre>

<p>This allows you to add a prefix to the backup file, instead of (or in addition to) a suffix:</p>

<pre><code class="plaintext">$ perl -pi&#39;orig_*&#39; -e &#39;s/bar/baz/&#39; fileA  # backup to
                                          # &#39;orig_fileA&#39;</code></pre>

<p>Or even to place backup copies of the original files into another directory (provided the directory already exists):</p>

<pre><code class="plaintext">$ perl -pi&#39;old/*.orig&#39; -e &#39;s/bar/baz/&#39; fileA  # backup to
                                              # &#39;old/fileA.orig&#39;</code></pre>

<p>These sets of one-liners are equivalent:</p>

<pre><code class="plaintext">$ perl -pi -e &#39;s/bar/baz/&#39; fileA          # overwrite current file
$ perl -pi&#39;*&#39; -e &#39;s/bar/baz/&#39; fileA       # overwrite current file

$ perl -pi&#39;.orig&#39; -e &#39;s/bar/baz/&#39; fileA   # backup to &#39;fileA.orig&#39;
$ perl -pi&#39;*.orig&#39; -e &#39;s/bar/baz/&#39; fileA  # backup to &#39;fileA.orig&#39;</code></pre>

<p>From the shell, saying</p>

<pre><code class="plaintext">$ perl -p -i.orig -e &quot;s/foo/bar/; ... &quot;</code></pre>

<p>is the same as using the program:</p>

<pre><code>#!/usr/bin/perl -pi.orig
s/foo/bar/;</code></pre>

<p>which is equivalent to</p>

<pre><code>    #!/usr/bin/perl
    $extension = &#39;.orig&#39;;
    LINE: while (&lt;&gt;) {
	if ($ARGV ne $oldargv) {
	    if ($extension !~ /\*/) {
		$backup = $ARGV . $extension;
	    }
	    else {
		($backup = $extension) =~ s/\*/$ARGV/g;
	    }
	    rename($ARGV, $backup);
	    open(ARGVOUT, &quot;&gt;$ARGV&quot;);
	    select(ARGVOUT);
	    $oldargv = $ARGV;
	}
	s/foo/bar/;
    }
    continue {
	print;	# this prints to original filename
    }
    select(STDOUT);</code></pre>

<p>except that the <b>-i</b> form doesn&#39;t need to compare $ARGV to $oldargv to know when the filename has changed. It does, however, use ARGVOUT for the selected filehandle. Note that STDOUT is restored as the default output filehandle after the loop.</p>

<p>As shown above, Perl creates the backup file whether or not any output is actually changed. So this is just a fancy way to copy files:</p>

<pre><code class="plaintext">$ perl -p -i&#39;/some/file/path/*&#39; -e 1 file1 file2 file3...
or
$ perl -p -i&#39;.orig&#39; -e 1 file1 file2 file3...</code></pre>

<p>You can use <code>eof</code> without parentheses to locate the end of each input file, in case you want to append to each file, or reset line numbering (see example in <a href="perlfunc.html#eof">&quot;eof&quot; in perlfunc</a>).</p>

<p>If, for a given file, Perl is unable to create the backup file as specified in the extension then it will skip that file and continue on with the next one (if it exists).</p>

<p>For a discussion of issues surrounding file permissions and <b>-i</b>, see <a href="perlfaq5.html#Why-does-Perl-let-me-delete-read-only-files%3F-Why-does-i-clobber-protected-files%3F-Isn%27t-this-a-bug-in-Perl%3F">&quot;Why does Perl let me delete read-only files? Why does -i clobber protected files? Isn&#39;t this a bug in Perl?&quot; in perlfaq5</a>.</p>

<p>You cannot use <b>-i</b> to create directories or to strip extensions from files.</p>

<p>Perl does not expand <code>~</code> in filenames, which is good, since some folks use it for their backup files:</p>

<pre><code class="plaintext">$ perl -pi~ -e &#39;s/foo/bar/&#39; file1 file2 file3...</code></pre>

<p>Note that because <b>-i</b> renames or deletes the original file before creating a new file of the same name, Unix-style soft and hard links will not be preserved.</p>

<p>Finally, the <b>-i</b> switch does not impede execution when no files are given on the command line. In this case, no backup is made (the original file cannot, of course, be determined) and processing proceeds from STDIN to STDOUT as might be expected.</p>

</dd>
<dt id="-Idirectory"><a class="permalink" href="perlrun.html#-Idirectory">#</a><a id="Idirectory"></a><b>-I</b><i>directory</i>  </dt>
<dd>

<p>Directories specified by <b>-I</b> are prepended to the search path for modules (<code>@INC</code>).</p>

</dd>
<dt id="-l[octnum]"><a class="permalink" href="perlrun.html#-l%5Boctnum%5D">#</a><a id="l-octnum"></a><b>-l</b>[<i>octnum</i>]   </dt>
<dd>

<p>enables automatic line-ending processing. It has two separate effects. First, it automatically chomps <code>$/</code> (the input record separator) when used with <a href="perlrun.html#-n">&quot;-n&quot;</a> or <a href="perlrun.html#-p">&quot;-p&quot;</a>. Second, it assigns <code>$\</code> (the output record separator) to have the value of <i>octnum</i> so that any print statements will have that separator added back on. If <i>octnum</i> is omitted, sets <code>$\</code> to the current value of <code>$/</code>. For instance, to trim lines to 80 columns:</p>

<pre><code>perl -lpe &#39;substr($_, 80) = &quot;&quot;&#39;</code></pre>

<p>Note that the assignment <code>$\ = $/</code> is done when the switch is processed, so the input record separator can be different than the output record separator if the <b>-l</b> switch is followed by a <a href="perlrun.html#-0%5Boctal%2Fhexadecimal%5D">-0</a> switch:</p>

<pre><code>gnufind / -print0 | perl -ln0e &#39;print &quot;found $_&quot; if -p&#39;</code></pre>

<p>This sets <code>$\</code> to newline and then sets <code>$/</code> to the null character.</p>

</dd>
<dt id="-m[-]module"><a class="permalink" href="perlrun.html#-m%5B-%5Dmodule">#</a><a id="m---module"></a><b>-m</b>[<b>-</b>]<i>module</i>  </dt>
<dd>

</dd>
<dt id="-M[-]module"><a class="permalink" href="perlrun.html#-M%5B-%5Dmodule">#</a><a id="M---module"></a><b>-M</b>[<b>-</b>]<i>module</i></dt>
<dd>

</dd>
<dt id="-M[-]&#39;module-...&#39;"><a class="permalink" href="perlrun.html#-M%5B-%5D&#39;module-...&#39;">#</a><a id="M---module1"></a><b>-M</b>[<b>-</b>]<i>&#39;module ...&#39;</i></dt>
<dd>

</dd>
<dt id="-[mM][-]module=arg[,arg]..."><a class="permalink" href="perlrun.html#-%5BmM%5D%5B-%5Dmodule=arg%5B,arg%5D...">#</a><a id="mM---module-arg-arg"></a><b>-[mM]</b>[<b>-</b>]<i>module=arg[,arg]...</i></dt>
<dd>

<p><b>-m</b><i>module</i> executes <code>use</code> <i>module</i> <code>();</code> before executing your program. This loads the module, but does not call its <code>import</code> method, so does not import subroutines and does not give effect to a pragma.</p>

<p><b>-M</b><i>module</i> executes <code>use</code> <i>module</i> <code>;</code> before executing your program. This loads the module and calls its <code>import</code> method, causing the module to have its default effect, typically importing subroutines or giving effect to a pragma. You can use quotes to add extra code after the module name, e.g., <code>&#39;-M<i>MODULE</i> qw(foo bar)&#39;</code>.</p>

<p>If the first character after the <b>-M</b> or <b>-m</b> is a dash (<b>-</b>) then the &#39;use&#39; is replaced with &#39;no&#39;. This makes no difference for <b>-m</b>.</p>

<p>A little builtin syntactic sugar means you can also say <b>-m<i>MODULE</i>=foo,bar</b> or <b>-M<i>MODULE</i>=foo,bar</b> as a shortcut for <b>&#39;-M<i>MODULE</i> qw(foo bar)&#39;</b>. This avoids the need to use quotes when importing symbols. The actual code generated by <b>-M<i>MODULE</i>=foo,bar</b> is <code>use module split(/,/,q{foo,bar})</code>. Note that the <code>=</code> form removes the distinction between <b>-m</b> and <b>-M</b>; that is, <b>-m<i>MODULE</i>=foo,bar</b> is the same as <b>-M<i>MODULE</i>=foo,bar</b>.</p>

<p>A consequence of the <code>split</code> formulation is that <b>-M<i>MODULE</i>=number</b> never does a version check, unless <code><i>MODULE</i>::import()</code> itself is set up to do a version check, which could happen for example if <i>MODULE</i> inherits from <a href="Exporter.html">Exporter</a>.</p>

</dd>
<dt id="-n"><a class="permalink" href="perlrun.html#-n">#</a><a id="n"></a><b>-n</b> </dt>
<dd>

<p>causes Perl to assume the following loop around your program, which makes it iterate over filename arguments somewhat like <i>sed -n</i> or <i>awk</i>:</p>

<pre><code>  LINE:
    while (&lt;&gt;) {
	...		# your program goes here
    }</code></pre>

<p>Note that the lines are not printed by default. See <a href="perlrun.html#-p">&quot;-p&quot;</a> to have lines printed. If a file named by an argument cannot be opened for some reason, Perl warns you about it and moves on to the next file.</p>

<p>Also note that <code>&lt;&gt;</code> passes command line arguments to <a href="perlfunc.html#open">&quot;open&quot; in perlfunc</a>, which doesn&#39;t necessarily interpret them as file names. See <a href="perlop.html">perlop</a> for possible security implications.</p>

<p>Here is an efficient way to delete all files that haven&#39;t been modified for at least a week:</p>

<pre><code class="plaintext">find . -mtime +7 -print | perl -nle unlink</code></pre>

<p>This is faster than using the <b>-exec</b> switch of <i>find</i> because you don&#39;t have to start a process on every filename found (but it&#39;s not faster than using the <b>-delete</b> switch available in newer versions of <i>find</i>. It does suffer from the bug of mishandling newlines in pathnames, which you can fix if you follow the example under <a href="perlrun.html#-0%5Boctal%2Fhexadecimal%5D">-0</a>.</p>

<p><code>BEGIN</code> and <code>END</code> blocks may be used to capture control before or after the implicit program loop, just as in <i>awk</i>.</p>

</dd>
<dt id="-p"><a class="permalink" href="perlrun.html#-p">#</a><a id="p"></a><b>-p</b> </dt>
<dd>

<p>causes Perl to assume the following loop around your program, which makes it iterate over filename arguments somewhat like <i>sed</i>:</p>

<pre><code>  LINE:
    while (&lt;&gt;) {
	...		# your program goes here
    } continue {
	print or die &quot;-p destination: $!\n&quot;;
    }</code></pre>

<p>If a file named by an argument cannot be opened for some reason, Perl warns you about it, and moves on to the next file. Note that the lines are printed automatically. An error occurring during printing is treated as fatal. To suppress printing use the <a href="perlrun.html#-n">&quot;-n&quot;</a> switch. A <b>-p</b> overrides a <b>-n</b> switch.</p>

<p><code>BEGIN</code> and <code>END</code> blocks may be used to capture control before or after the implicit loop, just as in <i>awk</i>.</p>

</dd>
<dt id="-s"><a class="permalink" href="perlrun.html#-s">#</a><a id="s"></a><b>-s</b> </dt>
<dd>

<p>enables rudimentary switch parsing for switches on the command line after the program name but before any filename arguments (or before an argument of <b>--</b>). Any switch found there is removed from @ARGV and sets the corresponding variable in the Perl program. The following program prints &quot;1&quot; if the program is invoked with a <b>-xyz</b> switch, and &quot;abc&quot; if it is invoked with <b>-xyz=abc</b>.</p>

<pre><code>#!/usr/bin/perl -s
if ($xyz) { print &quot;$xyz\n&quot; }</code></pre>

<p>Do note that a switch like <b>--help</b> creates the variable <code>${-help}</code>, which is not compliant with <code>use strict &quot;refs&quot;</code>. Also, when using this option on a script with warnings enabled you may get a lot of spurious &quot;used only once&quot; warnings.</p>

</dd>
<dt id="-S"><a class="permalink" href="perlrun.html#-S">#</a><a id="S"></a><b>-S</b> </dt>
<dd>

<p>makes Perl use the <a href="perlrun.html#PATH">&quot;PATH&quot;</a> environment variable to search for the program unless the name of the program contains path separators.</p>

<p>On some platforms, this also makes Perl append suffixes to the filename while searching for it. For example, on Win32 platforms, the &quot;.bat&quot; and &quot;.cmd&quot; suffixes are appended if a lookup for the original name fails, and if the name does not already end in one of those suffixes. If your Perl was compiled with <code>DEBUGGING</code> turned on, using the <a href="perlrun.html#-Dletters">-Dp</a> switch to Perl shows how the search progresses.</p>

<p>Typically this is used to emulate <code>#!</code> startup on platforms that don&#39;t support <code>#!</code>. It&#39;s also convenient when debugging a script that uses <code>#!</code>, and is thus normally found by the shell&#39;s $PATH search mechanism.</p>

<p>This example works on many platforms that have a shell compatible with Bourne shell:</p>

<pre><code>    #!/usr/bin/perl
    eval &#39;exec /usr/bin/perl -wS $0 ${1+&quot;$@&quot;}&#39;
	    if 0; # ^ Run only under a shell</code></pre>

<p>The system ignores the first line and feeds the program to <i>/bin/sh</i>, which proceeds to try to execute the Perl program as a shell script. The shell executes the second line as a normal shell command, and thus starts up the Perl interpreter. On some systems $0 doesn&#39;t always contain the full pathname, so the <a href="perlrun.html#-S">&quot;-S&quot;</a> tells Perl to search for the program if necessary. After Perl locates the program, it parses the lines and ignores them because the check &#39;if 0&#39; is never true. If the program will be interpreted by csh, you will need to replace <code>${1+&quot;$@&quot;}</code> with <code>$*</code>, even though that doesn&#39;t understand embedded spaces (and such) in the argument list. To start up <i>sh</i> rather than <i>csh</i>, some systems may have to replace the <code>#!</code> line with a line containing just a colon, which will be politely ignored by Perl. Other systems can&#39;t control that, and need a totally devious construct that will work under any of <i>csh</i>, <i>sh</i>, or Perl, such as the following:</p>

<pre><code>eval &#39;(exit $?0)&#39; &amp;&amp; eval &#39;exec perl -wS $0 ${1+&quot;$@&quot;}&#39;
&amp; eval &#39;exec /usr/bin/perl -wS $0 $argv:q&#39;
	if 0; # ^ Run only under a shell</code></pre>

<p>If the filename supplied contains directory separators (and so is an absolute or relative pathname), and if that file is not found, platforms that append file extensions will do so and try to look for the file with those extensions added, one by one.</p>

<p>On DOS-like platforms, if the program does not contain directory separators, it will first be searched for in the current directory before being searched for on the PATH. On Unix platforms, the program will be searched for strictly on the PATH.</p>

</dd>
<dt id="-t"><a class="permalink" href="perlrun.html#-t">#</a><a id="t"></a><b>-t</b> </dt>
<dd>

<p>Like <a href="perlrun.html#-T">&quot;-T&quot;</a>, but taint checks will issue warnings rather than fatal errors. These warnings can now be controlled normally with <code>no warnings qw(taint)</code>.</p>

<p><b>Note: This is not a substitute for <code>-T</code>!</b> This is meant to be used <i>only</i> as a temporary development aid while securing legacy code: for real production code and for new secure code written from scratch, always use the real <a href="perlrun.html#-T">&quot;-T&quot;</a>.</p>

</dd>
<dt id="-T"><a class="permalink" href="perlrun.html#-T">#</a><a id="T"></a><b>-T</b> </dt>
<dd>

<p>turns on &quot;taint&quot; so you can test them. Ordinarily these checks are done only when running setuid or setgid. It&#39;s a good idea to turn them on explicitly for programs that run on behalf of someone else whom you might not necessarily trust, such as CGI programs or any internet servers you might write in Perl. See <a href="perlsec.html">perlsec</a> for details. For security reasons, this option must be seen by Perl quite early; usually this means it must appear early on the command line or in the <code>#!</code> line for systems which support that construct.</p>

</dd>
<dt id="-u"><a class="permalink" href="perlrun.html#-u">#</a><a id="u"></a><b>-u</b> </dt>
<dd>

<p>This switch causes Perl to dump core after compiling your program. You can then in theory take this core dump and turn it into an executable file by using the <i>undump</i> program (not supplied). This speeds startup at the expense of some disk space (which you can minimize by stripping the executable). (Still, a &quot;hello world&quot; executable comes out to about 200K on my machine.) If you want to execute a portion of your program before dumping, use the <code>CORE::dump()</code> function instead. Note: availability of <i>undump</i> is platform specific and may not be available for a specific port of Perl.</p>

</dd>
<dt id="-U"><a class="permalink" href="perlrun.html#-U">#</a><a id="U"></a><b>-U</b> </dt>
<dd>

<p>allows Perl to do unsafe operations. Currently the only &quot;unsafe&quot; operations are attempting to unlink directories while running as superuser and running setuid programs with fatal taint checks turned into warnings. Note that warnings must be enabled along with this option to actually <i>generate</i> the taint-check warnings.</p>

</dd>
<dt id="-v"><a class="permalink" href="perlrun.html#-v">#</a><a id="v"></a><b>-v</b> </dt>
<dd>

<p>prints the version and patchlevel of your perl executable.</p>

</dd>
<dt id="-V"><a class="permalink" href="perlrun.html#-V">#</a><a id="V"></a><b>-V</b> </dt>
<dd>

<p>prints summary of the major perl configuration values and the current values of @INC.</p>

</dd>
<dt id="-V:configvar"><a class="permalink" href="perlrun.html#-V:configvar">#</a><a id="V:configvar"></a><b>-V:</b><i>configvar</i></dt>
<dd>

<p>Prints to STDOUT the value of the named configuration variable(s), with multiples when your <code><i>configvar</i></code> argument looks like a regex (has non-letters). For example:</p>

<pre><code>    $ perl -V:libc
	libc=&#39;/lib/libc-2.2.4.so&#39;;
    $ perl -V:lib.
	libs=&#39;-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc&#39;;
	libc=&#39;/lib/libc-2.2.4.so&#39;;
    $ perl -V:lib.*
	libpth=&#39;/usr/local/lib /lib /usr/lib&#39;;
	libs=&#39;-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc&#39;;
	lib_ext=&#39;.a&#39;;
	libc=&#39;/lib/libc-2.2.4.so&#39;;
	libperl=&#39;libperl.a&#39;;
	....</code></pre>

<p>Additionally, extra colons can be used to control formatting. A trailing colon suppresses the linefeed and terminator &quot;;&quot;, allowing you to embed queries into shell commands. (mnemonic: PATH separator &quot;:&quot;.)</p>

<pre><code class="plaintext">$ echo &quot;compression-vars: &quot; `perl -V:z.*: ` &quot; are here !&quot;
compression-vars:  zcat=&#39;&#39; zip=&#39;zip&#39;  are here !</code></pre>

<p>A leading colon removes the &quot;name=&quot; part of the response, this allows you to map to the name you need. (mnemonic: empty label)</p>

<pre><code>$ echo &quot;goodvfork=&quot;`./perl -Ilib -V::usevfork`
goodvfork=false;</code></pre>

<p>Leading and trailing colons can be used together if you need positional parameter values without the names. Note that in the case below, the <code>PERL_API</code> params are returned in alphabetical order.</p>

<pre><code class="plaintext">$ echo building_on `perl -V::osname: -V::PERL_API_.*:` now
building_on &#39;linux&#39; &#39;5&#39; &#39;1&#39; &#39;9&#39; now</code></pre>

</dd>
<dt id="-w"><a class="permalink" href="perlrun.html#-w">#</a><a id="w"></a><b>-w</b> </dt>
<dd>

<p>prints warnings about dubious constructs, such as variable names mentioned only once and scalar variables used before being set; redefined subroutines; references to undefined filehandles; filehandles opened read-only that you are attempting to write on; values used as a number that don&#39;t <i>look</i> like numbers; using an array as though it were a scalar; if your subroutines recurse more than 100 deep; and innumerable other things.</p>

<p>This switch really just enables the global <code>$^W</code> variable; normally, the lexically scoped <code>use warnings</code> pragma is preferred. You can disable or promote into fatal errors specific warnings using <code>__WARN__</code> hooks, as described in <a href="perlvar.html">perlvar</a> and <a href="perlfunc.html#warn">&quot;warn&quot; in perlfunc</a>. See also <a href="perldiag.html">perldiag</a> and <a href="perltrap.html">perltrap</a>. A fine-grained warning facility is also available if you want to manipulate entire classes of warnings; see <a href="warnings.html">warnings</a>.</p>

</dd>
<dt id="-W"><a class="permalink" href="perlrun.html#-W">#</a><a id="W"></a><b>-W</b> </dt>
<dd>

<p>Enables all warnings regardless of <code>no warnings</code> or <code>$^W</code>. See <a href="warnings.html">warnings</a>.</p>

</dd>
<dt id="-X"><a class="permalink" href="perlrun.html#-X">#</a><a id="X"></a><b>-X</b> </dt>
<dd>

<p>Disables all warnings regardless of <code>use warnings</code> or <code>$^W</code>. See <a href="warnings.html">warnings</a>.</p>

<p>Forbidden in <code><a href="perlrun.html#PERL5OPT">&quot;PERL5OPT&quot;</a></code>.</p>

</dd>
<dt id="-x"><a class="permalink" href="perlrun.html#-x">#</a><a id="x"></a><b>-x</b> </dt>
<dd>

</dd>
<dt id="-xdirectory"><a class="permalink" href="perlrun.html#-xdirectory">#</a><a id="xdirectory"></a><b>-x</b><i>directory</i></dt>
<dd>

<p>tells Perl that the program is embedded in a larger chunk of unrelated text, such as in a mail message. Leading garbage will be discarded until the first line that starts with <code>#!</code> and contains the string &quot;perl&quot;. Any meaningful switches on that line will be applied.</p>

<p>All references to line numbers by the program (warnings, errors, ...) will treat the <code>#!</code> line as the first line. Thus a warning on the 2nd line of the program, which is on the 100th line in the file will be reported as line 2, not as line 100. This can be overridden by using the <code>#line</code> directive. (See <a href="perlsyn.html#Plain-Old-Comments-%28Not%21%29">&quot;Plain Old Comments (Not!)&quot; in perlsyn</a>)</p>

<p>If a directory name is specified, Perl will switch to that directory before running the program. The <b>-x</b> switch controls only the disposal of leading garbage. The program must be terminated with <code>__END__</code> if there is trailing garbage to be ignored; the program can process any or all of the trailing garbage via the <code>DATA</code> filehandle if desired.</p>

<p>The directory, if specified, must appear immediately following the <b>-x</b> with no intervening whitespace.</p>

</dd>
</dl>

<h1 id="ENVIRONMENT"><a class="permalink" href="perlrun.html#ENVIRONMENT">#</a>ENVIRONMENT </h1>

<dl>

<dt id="HOME"><a class="permalink" href="perlrun.html#HOME">#</a>HOME </dt>
<dd>

<p>Used if <code>chdir</code> has no argument.</p>

</dd>
<dt id="LOGDIR"><a class="permalink" href="perlrun.html#LOGDIR">#</a>LOGDIR </dt>
<dd>

<p>Used if <code>chdir</code> has no argument and <a href="perlrun.html#HOME">&quot;HOME&quot;</a> is not set.</p>

</dd>
<dt id="PATH"><a class="permalink" href="perlrun.html#PATH">#</a>PATH </dt>
<dd>

<p>Used in executing subprocesses, and in finding the program if <a href="perlrun.html#-S">&quot;-S&quot;</a> is used.</p>

</dd>
<dt id="PERL5LIB"><a class="permalink" href="perlrun.html#PERL5LIB">#</a>PERL5LIB </dt>
<dd>

<p>A list of directories in which to look for Perl library files before looking in the standard library. Any architecture-specific and version-specific directories, such as <i>version/archname/</i>, <i>version/</i>, or <i>archname/</i> under the specified locations are automatically included if they exist, with this lookup done at interpreter startup time. In addition, any directories matching the entries in <code>$Config{inc_version_list}</code> are added. (These typically would be for older compatible perl versions installed in the same directory tree.)</p>

<p>If PERL5LIB is not defined, <a href="perlrun.html#PERLLIB">&quot;PERLLIB&quot;</a> is used. Directories are separated (like in PATH) by a colon on Unixish platforms and by a semicolon on Windows (the proper path separator being given by the command <code>perl -V:<i>path_sep</i></code>).</p>

<p>When running taint checks, either because the program was running setuid or setgid, or the <a href="perlrun.html#-T">&quot;-T&quot;</a> or <a href="perlrun.html#-t">&quot;-t&quot;</a> switch was specified, neither PERL5LIB nor <a href="perlrun.html#PERLLIB">&quot;PERLLIB&quot;</a> is consulted. The program should instead say:</p>

<pre><code>use lib &quot;/my/directory&quot;;</code></pre>

</dd>
<dt id="PERL5OPT"><a class="permalink" href="perlrun.html#PERL5OPT">#</a>PERL5OPT </dt>
<dd>

<p>Command-line options (switches). Switches in this variable are treated as if they were on every Perl command line. Only the <b>-[CDIMTUWdmtw]</b> switches are allowed. When running taint checks (either because the program was running setuid or setgid, or because the <a href="perlrun.html#-T">&quot;-T&quot;</a> or <a href="perlrun.html#-t">&quot;-t&quot;</a> switch was used), this variable is ignored. If PERL5OPT begins with <b>-T</b>, tainting will be enabled and subsequent options ignored. If PERL5OPT begins with <b>-t</b>, tainting will be enabled, a writable dot removed from @INC, and subsequent options honored.</p>

</dd>
<dt id="PERLIO"><a class="permalink" href="perlrun.html#PERLIO">#</a>PERLIO </dt>
<dd>

<p>A space (or colon) separated list of PerlIO layers. If perl is built to use PerlIO system for IO (the default) these layers affect Perl&#39;s IO.</p>

<p>It is conventional to start layer names with a colon (for example, <code>:perlio</code>) to emphasize their similarity to variable &quot;attributes&quot;. But the code that parses layer specification strings, which is also used to decode the PERLIO environment variable, treats the colon as a separator.</p>

<p>An unset or empty PERLIO is equivalent to the default set of layers for your platform; for example, <code>:unix:perlio</code> on Unix-like systems and <code>:unix:crlf</code> on Windows and other DOS-like systems.</p>

<p>The list becomes the default for <i>all</i> Perl&#39;s IO. Consequently only built-in layers can appear in this list, as external layers (such as <code>:encoding()</code>) need IO in order to load them! See <a href="open.html">&quot;open pragma&quot;</a> for how to add external encodings as defaults.</p>

<p>Layers it makes sense to include in the PERLIO environment variable are briefly summarized below. For more details see <a href="PerlIO.html">PerlIO</a>.</p>

<dl>

<dt id=":crlf"><a class="permalink" href="perlrun.html#:crlf">#</a><a id="crlf"></a>:crlf </dt>
<dd>

<p>A layer which does CRLF to <code>&quot;\n&quot;</code> translation distinguishing &quot;text&quot; and &quot;binary&quot; files in the manner of MS-DOS and similar operating systems, and also provides buffering similar to <code>:perlio</code> on these architectures.</p>

</dd>
<dt id=":perlio"><a class="permalink" href="perlrun.html#:perlio">#</a><a id="perlio"></a>:perlio </dt>
<dd>

<p>This is a re-implementation of stdio-like buffering written as a PerlIO layer. As such it will call whatever layer is below it for its operations, typically <code>:unix</code>.</p>

</dd>
<dt id=":stdio"><a class="permalink" href="perlrun.html#:stdio">#</a><a id="stdio"></a>:stdio </dt>
<dd>

<p>This layer provides a PerlIO interface by wrapping system&#39;s ANSI C &quot;stdio&quot; library calls. The layer provides both buffering and IO. Note that the <code>:stdio</code> layer does <i>not</i> do CRLF translation even if that is the platform&#39;s normal behaviour. You will need a <code>:crlf</code> layer above it to do that.</p>

</dd>
<dt id=":unix"><a class="permalink" href="perlrun.html#:unix">#</a><a id="unix"></a>:unix </dt>
<dd>

<p>Low-level layer that calls <code>read</code>, <code>write</code>, <code>lseek</code>, etc.</p>

</dd>
<dt id=":win32"><a class="permalink" href="perlrun.html#:win32">#</a><a id="win32"></a>:win32 </dt>
<dd>

<p>On Win32 platforms this <i>experimental</i> layer uses native &quot;handle&quot; IO rather than a Unix-like numeric file descriptor layer. Known to be buggy in this release (5.30).</p>

</dd>
</dl>

<p>The default set of layers should give acceptable results on all platforms.</p>

<p>For Unix platforms that will be the equivalent of &quot;:unix:perlio&quot; or &quot;:stdio&quot;. Configure is set up to prefer the &quot;:stdio&quot; implementation if the system&#39;s library provides for fast access to the buffer (not common on modern architectures); otherwise, it uses the &quot;:unix:perlio&quot; implementation.</p>

<p>On Win32 the default in this release (5.30) is &quot;:unix:crlf&quot;. Win32&#39;s &quot;:stdio&quot; has a number of bugs/mis-features for Perl IO which are somewhat depending on the version and vendor of the C compiler. Using our own <code>:crlf</code> layer as the buffer avoids those issues and makes things more uniform.</p>

<p>This release (5.30) uses <code>:unix</code> as the bottom layer on Win32, and so still uses the C compiler&#39;s numeric file descriptor routines. There is an experimental native <code>:win32</code> layer, which is expected to be enhanced and may eventually become the default under Win32.</p>

<p>The PERLIO environment variable is completely ignored when Perl is run in taint mode.</p>

</dd>
<dt id="PERLIO_DEBUG"><a class="permalink" href="perlrun.html#PERLIO_DEBUG">#</a>PERLIO_DEBUG </dt>
<dd>

<p>If set to the name of a file or device when Perl is run with the <a href="perlrun.html#-Dletters">-Di</a> command-line switch, the logging of certain operations of the PerlIO subsystem will be redirected to the specified file rather than going to stderr, which is the default. The file is opened in append mode. Typical uses are in Unix:</p>

<pre><code class="plaintext">% env PERLIO_DEBUG=/tmp/perlio.log perl -Di script ...</code></pre>

<p>and under Win32, the approximately equivalent:</p>

<pre><code class="plaintext">&gt; set PERLIO_DEBUG=CON
perl -Di script ...</code></pre>

<p>This functionality is disabled for setuid scripts, for scripts run with <a href="perlrun.html#-T">&quot;-T&quot;</a>, and for scripts run on a Perl built without <code>-DDEBUGGING</code> support.</p>

</dd>
<dt id="PERLLIB"><a class="permalink" href="perlrun.html#PERLLIB">#</a>PERLLIB </dt>
<dd>

<p>A list of directories in which to look for Perl library files before looking in the standard library. If <a href="perlrun.html#PERL5LIB">&quot;PERL5LIB&quot;</a> is defined, PERLLIB is not used.</p>

<p>The PERLLIB environment variable is completely ignored when Perl is run in taint mode.</p>

</dd>
<dt id="PERL5DB"><a class="permalink" href="perlrun.html#PERL5DB">#</a>PERL5DB </dt>
<dd>

<p>The command used to load the debugger code. The default is:</p>

<pre><code class="plaintext">BEGIN { require &quot;perl5db.pl&quot; }</code></pre>

<p>The PERL5DB environment variable is only used when Perl is started with a bare <a href="perlrun.html#-d">&quot;-d&quot;</a> switch.</p>

</dd>
<dt id="PERL5DB_THREADED"><a class="permalink" href="perlrun.html#PERL5DB_THREADED">#</a>PERL5DB_THREADED </dt>
<dd>

<p>If set to a true value, indicates to the debugger that the code being debugged uses threads.</p>

</dd>
<dt id="PERL5SHELL-(specific-to-the-Win32-port)"><a class="permalink" href="perlrun.html#PERL5SHELL-(specific-to-the-Win32-port)">#</a><a id="PERL5SHELL"></a><a id="PERL5SHELL-specific-to-the-Win32-port"></a>PERL5SHELL (specific to the Win32 port) </dt>
<dd>

<p>On Win32 ports only, may be set to an alternative shell that Perl must use internally for executing &quot;backtick&quot; commands or system(). Default is <code>cmd.exe /x/d/c</code> on WindowsNT and <code>command.com /c</code> on Windows95. The value is considered space-separated. Precede any character that needs to be protected, like a space or backslash, with another backslash.</p>

<p>Note that Perl doesn&#39;t use COMSPEC for this purpose because COMSPEC has a high degree of variability among users, leading to portability concerns. Besides, Perl can use a shell that may not be fit for interactive use, and setting COMSPEC to such a shell may interfere with the proper functioning of other programs (which usually look in COMSPEC to find a shell fit for interactive use).</p>

<p>Before Perl 5.10.0 and 5.8.8, PERL5SHELL was not taint checked when running external commands. It is recommended that you explicitly set (or delete) <code>$ENV{PERL5SHELL}</code> when running in taint mode under Windows.</p>

</dd>
<dt id="PERL_ALLOW_NON_IFS_LSP-(specific-to-the-Win32-port)"><a class="permalink" href="perlrun.html#PERL_ALLOW_NON_IFS_LSP-(specific-to-the-Win32-port)">#</a><a id="PERL_ALLOW_NON_IFS_LSP"></a><a id="PERL_ALLOW_NON_IFS_LSP-specific-to-the-Win32-port"></a>PERL_ALLOW_NON_IFS_LSP (specific to the Win32 port) </dt>
<dd>

<p>Set to 1 to allow the use of non-IFS compatible LSPs (Layered Service Providers). Perl normally searches for an IFS-compatible LSP because this is required for its emulation of Windows sockets as real filehandles. However, this may cause problems if you have a firewall such as <i>McAfee Guardian</i>, which requires that all applications use its LSP but which is not IFS-compatible, because clearly Perl will normally avoid using such an LSP.</p>

<p>Setting this environment variable to 1 means that Perl will simply use the first suitable LSP enumerated in the catalog, which keeps <i>McAfee Guardian</i> happy--and in that particular case Perl still works too because <i>McAfee Guardian</i>&#39;s LSP actually plays other games which allow applications requiring IFS compatibility to work.</p>

</dd>
<dt id="PERL_DEBUG_MSTATS"><a class="permalink" href="perlrun.html#PERL_DEBUG_MSTATS">#</a>PERL_DEBUG_MSTATS </dt>
<dd>

<p>Relevant only if Perl is compiled with the <code>malloc</code> included with the Perl distribution; that is, if <code>perl -V:d_mymalloc</code> is &quot;define&quot;.</p>

<p>If set, this dumps out memory statistics after execution. If set to an integer greater than one, also dumps out memory statistics after compilation.</p>

</dd>
<dt id="PERL_DESTRUCT_LEVEL"><a class="permalink" href="perlrun.html#PERL_DESTRUCT_LEVEL">#</a>PERL_DESTRUCT_LEVEL </dt>
<dd>

<p>Controls the behaviour of global destruction of objects and other references. See <a href="perlhacktips.html#PERL_DESTRUCT_LEVEL">&quot;PERL_DESTRUCT_LEVEL&quot; in perlhacktips</a> for more information.</p>

</dd>
<dt id="PERL_DL_NONLAZY"><a class="permalink" href="perlrun.html#PERL_DL_NONLAZY">#</a>PERL_DL_NONLAZY </dt>
<dd>

<p>Set to <code>&quot;1&quot;</code> to have Perl resolve <i>all</i> undefined symbols when it loads a dynamic library. The default behaviour is to resolve symbols when they are used. Setting this variable is useful during testing of extensions, as it ensures that you get an error on misspelled function names even if the test suite doesn&#39;t call them.</p>

</dd>
<dt id="PERL_ENCODING"><a class="permalink" href="perlrun.html#PERL_ENCODING">#</a>PERL_ENCODING </dt>
<dd>

<p>If using the <code>use encoding</code> pragma without an explicit encoding name, the PERL_ENCODING environment variable is consulted for an encoding name.</p>

</dd>
<dt id="PERL_HASH_SEED"><a class="permalink" href="perlrun.html#PERL_HASH_SEED">#</a>PERL_HASH_SEED </dt>
<dd>

<p>(Since Perl 5.8.1, new semantics in Perl 5.18.0) Used to override the randomization of Perl&#39;s internal hash function. The value is expressed in hexadecimal, and may include a leading 0x. Truncated patterns are treated as though they are suffixed with sufficient 0&#39;s as required.</p>

<p>If the option is provided, and <code>PERL_PERTURB_KEYS</code> is NOT set, then a value of &#39;0&#39; implies <code>PERL_PERTURB_KEYS=0</code> and any other value implies <code>PERL_PERTURB_KEYS=2</code>.</p>

<p><b>PLEASE NOTE: The hash seed is sensitive information</b>. Hashes are randomized to protect against local and remote attacks against Perl code. By manually setting a seed, this protection may be partially or completely lost.</p>

<p>See <a href="perlsec.html#Algorithmic-Complexity-Attacks">&quot;Algorithmic Complexity Attacks&quot; in perlsec</a>, <a href="perlrun.html#PERL_PERTURB_KEYS">&quot;PERL_PERTURB_KEYS&quot;</a>, and <a href="perlrun.html#PERL_HASH_SEED_DEBUG">&quot;PERL_HASH_SEED_DEBUG&quot;</a> for more information.</p>

</dd>
<dt id="PERL_PERTURB_KEYS"><a class="permalink" href="perlrun.html#PERL_PERTURB_KEYS">#</a>PERL_PERTURB_KEYS </dt>
<dd>

<p>(Since Perl 5.18.0) Set to <code>&quot;0&quot;</code> or <code>&quot;NO&quot;</code> then traversing keys will be repeatable from run to run for the same <code>PERL_HASH_SEED</code>. Insertion into a hash will not change the order, except to provide for more space in the hash. When combined with setting PERL_HASH_SEED this mode is as close to pre 5.18 behavior as you can get.</p>

<p>When set to <code>&quot;1&quot;</code> or <code>&quot;RANDOM&quot;</code> then traversing keys will be randomized. Every time a hash is inserted into the key order will change in a random fashion. The order may not be repeatable in a following program run even if the PERL_HASH_SEED has been specified. This is the default mode for perl.</p>

<p>When set to <code>&quot;2&quot;</code> or <code>&quot;DETERMINISTIC&quot;</code> then inserting keys into a hash will cause the key order to change, but in a way that is repeatable from program run to program run.</p>

<p><b>NOTE:</b> Use of this option is considered insecure, and is intended only for debugging non-deterministic behavior in Perl&#39;s hash function. Do not use it in production.</p>

<p>See <a href="perlsec.html#Algorithmic-Complexity-Attacks">&quot;Algorithmic Complexity Attacks&quot; in perlsec</a> and <a href="perlrun.html#PERL_HASH_SEED">&quot;PERL_HASH_SEED&quot;</a> and <a href="perlrun.html#PERL_HASH_SEED_DEBUG">&quot;PERL_HASH_SEED_DEBUG&quot;</a> for more information. You can get and set the key traversal mask for a specific hash by using the <code>hash_traversal_mask()</code> function from <a href="./Hash::Util.html">Hash::Util</a>.</p>

</dd>
<dt id="PERL_HASH_SEED_DEBUG"><a class="permalink" href="perlrun.html#PERL_HASH_SEED_DEBUG">#</a>PERL_HASH_SEED_DEBUG </dt>
<dd>

<p>(Since Perl 5.8.1.) Set to <code>&quot;1&quot;</code> to display (to STDERR) information about the hash function, seed, and what type of key traversal randomization is in effect at the beginning of execution. This, combined with <a href="perlrun.html#PERL_HASH_SEED">&quot;PERL_HASH_SEED&quot;</a> and <a href="perlrun.html#PERL_PERTURB_KEYS">&quot;PERL_PERTURB_KEYS&quot;</a> is intended to aid in debugging nondeterministic behaviour caused by hash randomization.</p>

<p><b>Note</b> that any information about the hash function, especially the hash seed is <b>sensitive information</b>: by knowing it, one can craft a denial-of-service attack against Perl code, even remotely; see <a href="perlsec.html#Algorithmic-Complexity-Attacks">&quot;Algorithmic Complexity Attacks&quot; in perlsec</a> for more information. <b>Do not disclose the hash seed</b> to people who don&#39;t need to know it. See also <a href="./Hash::Util.html#hash_seed"><code>hash_seed()</code></a> and <a href="./Hash::Util.html#hash_traversal_mask"><code>hash_traversal_mask()</code></a>.</p>

<p>An example output might be:</p>

<pre><code class="plaintext">HASH_FUNCTION = ONE_AT_A_TIME_HARD HASH_SEED = 0x652e9b9349a7a032 PERTURB_KEYS = 1 (RANDOM)</code></pre>

</dd>
<dt id="PERL_MEM_LOG"><a class="permalink" href="perlrun.html#PERL_MEM_LOG">#</a>PERL_MEM_LOG </dt>
<dd>

<p>If your Perl was configured with <b>-Accflags=-DPERL_MEM_LOG</b>, setting the environment variable <code>PERL_MEM_LOG</code> enables logging debug messages. The value has the form <code>&lt;<i>number</i>&gt;[m][s][t]</code>, where <code><i>number</i></code> is the file descriptor number you want to write to (2 is default), and the combination of letters specifies that you want information about (m)emory and/or (s)v, optionally with (t)imestamps. For example, <code>PERL_MEM_LOG=1mst</code> logs all information to stdout. You can write to other opened file descriptors in a variety of ways:</p>

<pre><code class="plaintext">$ 3&gt;foo3 PERL_MEM_LOG=3m perl ...</code></pre>

</dd>
<dt id="PERL_ROOT-(specific-to-the-VMS-port)"><a class="permalink" href="perlrun.html#PERL_ROOT-(specific-to-the-VMS-port)">#</a><a id="PERL_ROOT"></a><a id="PERL_ROOT-specific-to-the-VMS-port"></a>PERL_ROOT (specific to the VMS port) </dt>
<dd>

<p>A translation-concealed rooted logical name that contains Perl and the logical device for the @INC path on VMS only. Other logical names that affect Perl on VMS include PERLSHR, PERL_ENV_TABLES, and SYS$TIMEZONE_DIFFERENTIAL, but are optional and discussed further in <a href="perlvms.html">perlvms</a> and in <i>README.vms</i> in the Perl source distribution.</p>

</dd>
<dt id="PERL_SIGNALS"><a class="permalink" href="perlrun.html#PERL_SIGNALS">#</a>PERL_SIGNALS </dt>
<dd>

<p>Available in Perls 5.8.1 and later. If set to <code>&quot;unsafe&quot;</code>, the pre-Perl-5.8.0 signal behaviour (which is immediate but unsafe) is restored. If set to <code>safe</code>, then safe (but deferred) signals are used. See <a href="perlipc.html#Deferred-Signals-%28Safe-Signals%29">&quot;Deferred Signals (Safe Signals)&quot; in perlipc</a>.</p>

</dd>
<dt id="PERL_UNICODE"><a class="permalink" href="perlrun.html#PERL_UNICODE">#</a>PERL_UNICODE </dt>
<dd>

<p>Equivalent to the <a href="perlrun.html#-C-%5Bnumber%2Flist%5D">-C</a> command-line switch. Note that this is not a boolean variable. Setting this to <code>&quot;1&quot;</code> is not the right way to &quot;enable Unicode&quot; (whatever that would mean). You can use <code>&quot;0&quot;</code> to &quot;disable Unicode&quot;, though (or alternatively unset PERL_UNICODE in your shell before starting Perl). See the description of the <a href="perlrun.html#-C-%5Bnumber%2Flist%5D">-C</a> switch for more information.</p>

</dd>
<dt id="PERL_USE_UNSAFE_INC"><a class="permalink" href="perlrun.html#PERL_USE_UNSAFE_INC">#</a>PERL_USE_UNSAFE_INC </dt>
<dd>

<p>If perl has been configured to not have the current directory in <a href="perlvar.html#%40INC"><code>@INC</code></a> by default, this variable can be set to <code>&quot;1&quot;</code> to reinstate it. It&#39;s primarily intended for use while building and testing modules that have not been updated to deal with &quot;.&quot; not being in <code>@INC</code> and should not be set in the environment for day-to-day use.</p>

</dd>
<dt id="SYS$LOGIN-(specific-to-the-VMS-port)"><a class="permalink" href="perlrun.html#SYS$LOGIN-(specific-to-the-VMS-port)">#</a><a id="SYS"></a><a id="SYS-LOGIN-specific-to-the-VMS-port"></a>SYS$LOGIN (specific to the VMS port) </dt>
<dd>

<p>Used if chdir has no argument and <a href="perlrun.html#HOME">&quot;HOME&quot;</a> and <a href="perlrun.html#LOGDIR">&quot;LOGDIR&quot;</a> are not set.</p>

</dd>
<dt id="PERL_INTERNAL_RAND_SEED"><a class="permalink" href="perlrun.html#PERL_INTERNAL_RAND_SEED">#</a>PERL_INTERNAL_RAND_SEED </dt>
<dd>

<p>Set to a non-negative integer to seed the random number generator used internally by perl for a variety of purposes.</p>

<p>Ignored if perl is run setuid or setgid. Used only for some limited startup randomization (hash keys) if <code>-T</code> or <code>-t</code> perl is started with tainting enabled.</p>

<p>Perl may be built to ignore this variable.</p>

</dd>
</dl>

<p>Perl also has environment variables that control how Perl handles data specific to particular natural languages; see <a href="perllocale.html">perllocale</a>.</p>

<p>Perl and its various modules and components, including its test frameworks, may sometimes make use of certain other environment variables. Some of these are specific to a particular platform. Please consult the appropriate module documentation and any documentation for your platform (like <a href="perlsolaris.html">perlsolaris</a>, <a href="perllinux.html">perllinux</a>, <a href="perlmacosx.html">perlmacosx</a>, <a href="perlwin32.html">perlwin32</a>, etc) for variables peculiar to those specific situations.</p>

<p>Perl makes all environment variables available to the program being executed, and passes these along to any child processes it starts. However, programs running setuid would do well to execute the following lines before doing anything else, just to keep people honest:</p>

<pre><code>$ENV{PATH}  = &quot;/bin:/usr/bin&quot;;    # or whatever you need
$ENV{SHELL} = &quot;/bin/sh&quot; if exists $ENV{SHELL};
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};</code></pre>

<h1 id="ORDER-OF-APPLICATION"><a class="permalink" href="perlrun.html#ORDER-OF-APPLICATION">#</a><a id="ORDER"></a>ORDER OF APPLICATION</h1>

<p>Some options, in particular <code>-I</code>, <code>-M</code>, <code>PERL5LIB</code> and <code>PERL5OPT</code> can interact, and the order in which they are applied is important.</p>

<p>Note that this section does not document what <i>actually</i> happens inside the perl interpreter, it documents what <i>effectively</i> happens.</p>

<dl>

<dt id="-I"><a class="permalink" href="perlrun.html#-I">#</a><a id="I"></a>-I</dt>
<dd>

<p>The effect of multiple <code>-I</code> options is to <code>unshift</code> them onto <code>@INC</code> from right to left. So for example:</p>

<pre><code class="plaintext">perl -I 1 -I 2 -I 3</code></pre>

<p>will first prepend <code>3</code> onto the front of <code>@INC</code>, then prepend <code>2</code>, and then prepend <code>1</code>. The result is that <code>@INC</code> begins with:</p>

<pre><code class="plaintext">qw(1 2 3)</code></pre>

</dd>
<dt id="-M"><a class="permalink" href="perlrun.html#-M">#</a><a id="M"></a>-M</dt>
<dd>

<p>Multiple <code>-M</code> options are processed from left to right. So this:</p>

<pre><code class="plaintext">perl -Mlib=1 -Mlib=2 -Mlib=3</code></pre>

<p>will first use the <a href="lib.html">lib</a> pragma to prepend <code>1</code> to <code>@INC</code>, then it will prepend <code>2</code>, then it will prepend <code>3</code>, resulting in an <code>@INC</code> that begins with:</p>

<pre><code class="plaintext">qw(3 2 1)</code></pre>

</dd>
<dt id="the-PERL5LIB-environment-variable"><a class="permalink" href="perlrun.html#the-PERL5LIB-environment-variable">#</a><a id="the"></a>the PERL5LIB environment variable</dt>
<dd>

<p>This contains a list of directories, separated by colons. The entire list is prepended to <code>@INC</code> in one go. This:</p>

<pre><code class="plaintext">PERL5LIB=1:2:3 perl</code></pre>

<p>will result in an <code>@INC</code> that begins with:</p>

<pre><code class="plaintext">qw(1 2 3)</code></pre>

</dd>
<dt id="combinations-of-I,-M-and-PERL5LIB"><a class="permalink" href="perlrun.html#combinations-of-I,-M-and-PERL5LIB">#</a><a id="combinations"></a><a id="combinations-of--I--M-and-PERL5LIB"></a>combinations of -I, -M and PERL5LIB</dt>
<dd>

<p><code>PERL5LIB</code> is applied first, then all the <code>-I</code> arguments, then all the <code>-M</code> arguments. This:</p>

<pre><code class="plaintext">PERL5LIB=e1:e2 perl -I i1 -Mlib=m1 -I i2 -Mlib=m2</code></pre>

<p>will result in an <code>@INC</code> that begins with:</p>

<pre><code class="plaintext">qw(m2 m1 i1 i2 e1 e2)</code></pre>

</dd>
<dt id="the-PERL5OPT-environment-variable"><a class="permalink" href="perlrun.html#the-PERL5OPT-environment-variable">#</a><a id="the1"></a>the PERL5OPT environment variable</dt>
<dd>

<p>This contains a space separated list of switches. We only consider the effects of <code>-M</code> and <code>-I</code> in this section.</p>

<p>After normal processing of <code>-I</code> switches from the command line, all the <code>-I</code> switches in <code>PERL5OPT</code> are extracted. They are processed from left to right instead of from right to left. Also note that while whitespace is allowed between a <code>-I</code> and its directory on the command line, it is not allowed in <code>PERL5OPT</code>.</p>

<p>After normal processing of <code>-M</code> switches from the command line, all the <code>-M</code> switches in <code>PERL5OPT</code> are extracted. They are processed from left to right, <i>i.e.</i> the same as those on the command line.</p>

<p>An example may make this clearer:</p>

<pre><code class="plaintext">export PERL5OPT=&quot;-Mlib=optm1 -Iopti1 -Mlib=optm2 -Iopti2&quot;
export PERL5LIB=e1:e2
perl -I i1 -Mlib=m1 -I i2 -Mlib=m2</code></pre>

<p>will result in an <code>@INC</code> that begins with:</p>

<pre><code class="plaintext">qw(
    optm2
    optm1

    m2
    m1

    opti2
    opti1

    i1
    i2

    e1
    e2
)</code></pre>

</dd>
<dt id="Other-complications"><a class="permalink" href="perlrun.html#Other-complications">#</a><a id="Other"></a>Other complications</dt>
<dd>

<p>There are some complications that are ignored in the examples above:</p>

<dl>

<dt id="arch-and-version-subdirs"><a class="permalink" href="perlrun.html#arch-and-version-subdirs">#</a><a id="arch"></a>arch and version subdirs</dt>
<dd>

<p>All of <code>-I</code>, <code>PERL5LIB</code> and <code>use lib</code> will also prepend arch and version subdirs if they are present</p>

</dd>
<dt id="sitecustomize.pl"><a class="permalink" href="perlrun.html#sitecustomize.pl">#</a><a id="sitecustomize"></a>sitecustomize.pl</dt>
<dd>

</dd>
</dl>

</dd>
</dl>


      </div>
      <div id="footer">
        <p>Perldoc Browser is maintained by Dan Book (<a href="https://metacpan.org/author/DBOOK">DBOOK</a>). Please contact him via the <a href="https://github.com/Grinnz/perldoc-browser/issues">GitHub issue tracker</a> or <a href="mailto:dbook@cpan.org">email</a> regarding any issues with the site itself, search, or rendering of documentation.</p>

<p>The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the <a href="https://github.com/Perl/perl5/issues">Perl issue tracker</a>, the <a href="https://lists.perl.org/list/perl5-porters.html">mailing list</a>, or <a href="https://kiwiirc.com/client/irc.perl.org/p5p">IRC</a> to report any issues with the contents or format of the documentation.</p>


      </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
    <script src="../highlight.pack.js"></script>
    <script>hljs.highlightAll();</script>
  </body>
</html>
